package com.baiye.www.config;

import com.baiye.www.serializer.SerializeType;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * @author GUOZHIPENG
 * @version 1.0
 * @date 2021/12/2 8:23
 */
public class Config {
    public static int PORT;
    public static String IP;
    public static SerializeType SERIALIZER;
    static {

        Properties props = new Properties();
        try(InputStream in=Config.class.getResourceAsStream("/application.properties");) {
            props.load(in);
            String port=props.getProperty("server.port","8080");
            PORT=Integer.parseInt(port);
            String ip=props.getProperty("server.ip","127.0.0.1");
            IP=ip;
            String serializer=props.getProperty("serializer.algorithm","Json");
            SERIALIZER=SerializeType.valueOf(serializer);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
